package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ScreenServiceGuanranteeDTO;
import com.hzeport.bgs22emduty.dto.ScreenServiceGuanranteeSaveDTO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.entity.ScreenServiceGuanrantee;
import com.hzeport.bgs22emduty.service.ScreenServiceGuanranteeService;
//import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screenserviceguanrantee")
@Api(value = "screenserviceguanrantee", tags = "服务保障管理")
@Slf4j
public class ScreenServiceGuanranteeController {

    private final ScreenServiceGuanranteeService screenServiceGuanranteeService;

    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public BaseResult getScreenServiceGuanranteePage(@RequestBody ScreenServiceGuanranteeDTO dto) {
        return BaseResult.ok(screenServiceGuanranteeService.getScreenServiceGuanranteePage(dto));
    }

    @ApiOperation(value = "新增", notes = "新增")
    @PostMapping("save")
    @OperLog( systemName = "FWBZ", description = "BZXZ")
    public BaseResult save(@RequestBody ScreenServiceGuanranteeSaveDTO screenServiceGuanranteeSaveDTO) {
        return BaseResult.ok(screenServiceGuanranteeService.save(screenServiceGuanranteeSaveDTO));
    }


    /**
     * 通过id查询${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public BaseResult getById(@PathVariable("id") String id) {
        return BaseResult.ok(screenServiceGuanranteeService.getById(id));
    }

    /**
     * 修改${comments}
     * @param screenServiceGuanrantee ${comments}
     * @return R
     */
    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
//    @SysLog(.*)
    @PostMapping
    @OperLog( systemName = "FWBZ", description = "BZXG")
    public BaseResult updateById(@RequestBody ScreenServiceGuanrantee screenServiceGuanrantee) {
        String id = screenServiceGuanrantee.getId();
        if (!StringUtils.isBlank(id)){
            ScreenServiceGuanrantee byId = screenServiceGuanranteeService.getById(id);
            if (byId != null){
                screenServiceGuanrantee.setRecVersion(byId.getRecVersion());
            }
        }
        return BaseResult.ok(screenServiceGuanranteeService.updateById(screenServiceGuanrantee));
    }

    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
    //@SysLog(.*)
    @DeleteMapping("/{id}")
    @OperLog( systemName = "FWBZ", description = "BZSC")
    public BaseResult removeById(@PathVariable String id) {
        return BaseResult.ok(screenServiceGuanranteeService.removeById(id));
    }

}
